\hypertarget{cluster_8h}{
\section{Referência ao ficheiro cluster.h}
\label{cluster_8h}\index{cluster.h@{cluster.h}}
}
Arquivo responsável por gerenciar (incluir/remover/buscar) os servidores do \hyperlink{structcluster}{cluster} L2LB. 

\subsection*{Estruturas de Dados}
\begin{CompactItemize}
\item 
struct \hyperlink{structcluster__node}{cluster\_\-node}
\begin{CompactList}\small\item\em Nó do \hyperlink{structcluster}{cluster}. \item\end{CompactList}\item 
struct \hyperlink{structcluster}{cluster}
\begin{CompactList}\small\item\em Cluster. \item\end{CompactList}\end{CompactItemize}
\subsection*{Funções}
\begin{CompactItemize}
\item 
void \hyperlink{cluster_8h_1cacc18d29de69dfe9b47ee4eb5e7600}{hb\_\-timer\_\-add} (struct \hyperlink{structcluster__node}{cluster\_\-node} $\ast$new\_\-node)
\begin{CompactList}\small\item\em Prepara o servidor adicionado ao \hyperlink{structcluster}{cluster} para ser removido do \hyperlink{structcluster}{cluster} se nao receber o heartbeat. \item\end{CompactList}\item 
int \hyperlink{cluster_8h_25dbc05b5c8157863bcb1801c17f77c1}{hb\_\-broadcast\_\-msg} (char $\ast$buf, int buf\_\-len)
\begin{CompactList}\small\item\em Envia uma mensagem em Brodcast para todos os nós do \hyperlink{structcluster}{cluster}. \item\end{CompactList}\item 
void \hyperlink{cluster_8h_28ab4480aefa945c08a4d1f5e16a8d5e}{hash\_\-remove\_\-node\_\-affinities} (struct \hyperlink{structcluster__node}{cluster\_\-node} $\ast$node)
\begin{CompactList}\small\item\em Remove todas as afinidades de um servidor Metodo usado na hora de remover um servidor do \hyperlink{structcluster}{cluster}. \item\end{CompactList}\item 
static struct \hyperlink{structcluster__node}{cluster\_\-node} $\ast$ \hyperlink{cluster_8h_a568a7669c4ee6f27338231d23575c13}{add\_\-cluster\_\-node} (int id, u32 vlan\_\-ip)
\begin{CompactList}\small\item\em Registra um novo servidor do \hyperlink{structcluster}{cluster}. \item\end{CompactList}\item 
void \hyperlink{cluster_8h_c55a15a79cadec11fb3d6df11ac5f4e7}{remove\_\-cluster\_\-node} (unsigned long node\_\-ptr)
\begin{CompactList}\small\item\em Remove um servidor do \hyperlink{structcluster}{cluster}\begin{itemize}
\item Remove o servidor da lista de servidores,\item Notifica os demais servidores da exclusao deste servidor. \end{itemize}
\item\end{CompactList}\item 
struct \hyperlink{structcluster__node}{cluster\_\-node} $\ast$ \hyperlink{cluster_8h_4e116ec9395a6720c5f84de3e28b25a9}{get\_\-node\_\-by\_\-id} (int id)
\begin{CompactList}\small\item\em Busca um servidor do \hyperlink{structcluster}{cluster} pelo ID. \item\end{CompactList}\item 
static int \hyperlink{cluster_8h_33d0ab81e5ab7cf05146cead194236b7}{init\_\-cluster} (char $\ast$\hyperlink{nlb-driver_8c_312f6a236fcec7f8803e170412fb3f86}{dev}, char $\ast$\hyperlink{nlb-driver_8c_c8f175c78fae68f5348eab7bcc8ca54b}{ip}, int($\ast$hard\_\-start\_\-xmit\_\-new)(struct sk\_\-buff $\ast$skb, struct net\_\-device $\ast$\hyperlink{nlb-driver_8c_312f6a236fcec7f8803e170412fb3f86}{dev}))
\begin{CompactList}\small\item\em Inicializa a estrutura my\_\-cluster. \item\end{CompactList}\item 
static int \hyperlink{cluster_8h_aa5aa80302607600a63f6b78dc842b75}{nlb\_\-cluster\_\-exit} (void)
\begin{CompactList}\small\item\em Finaliza o \hyperlink{structcluster}{cluster}. \item\end{CompactList}\end{CompactItemize}
\subsection*{Variáveis}
\begin{CompactItemize}
\item 
struct \hyperlink{structcluster__node}{cluster\_\-node} \hyperlink{cluster_8h_39e3ce09327c335c6a58f152f9d8fbbf}{my\_\-node}
\begin{CompactList}\small\item\em Nó do \hyperlink{structcluster}{cluster}. \item\end{CompactList}\item 
struct \hyperlink{structcluster}{cluster} \hyperlink{cluster_8h_1917b2709741dea7ce5cf6ea441686ed}{my\_\-cluster}
\begin{CompactList}\small\item\em Cluster. \item\end{CompactList}\end{CompactItemize}


\subsection{Descrição detalhada}
Arquivo responsável por gerenciar (incluir/remover/buscar) os servidores do \hyperlink{structcluster}{cluster} L2LB. 



Definido no ficheiro \hyperlink{cluster_8h-source}{cluster.h}.

\subsection{Documentação das funções}
\hypertarget{cluster_8h_a568a7669c4ee6f27338231d23575c13}{
\index{cluster.h@{cluster.h}!add\_\-cluster\_\-node@{add\_\-cluster\_\-node}}
\index{add\_\-cluster\_\-node@{add\_\-cluster\_\-node}!cluster.h@{cluster.h}}
\subsubsection[add\_\-cluster\_\-node]{\setlength{\rightskip}{0pt plus 5cm}static struct {\bf cluster\_\-node}$\ast$ add\_\-cluster\_\-node (int {\em id}, \/  u32 {\em vlan\_\-ip})\hspace{0.3cm}{\tt  \mbox{[}static, read\mbox{]}}}}
\label{cluster_8h_a568a7669c4ee6f27338231d23575c13}


Registra um novo servidor do \hyperlink{structcluster}{cluster}. 

\begin{Desc}
\item[Parâmetros:]
\begin{description}
\item[{\em id}]ID do servidor \item[{\em vlan\_\-ip}]VIP do servidor \end{description}
\end{Desc}


Definido na linha 77 do ficheiro cluster.h.

Referências hb\_\-timer\_\-add(), cluster::head, cluster\_\-node::id, my\_\-cluster, cluster\_\-node::next, cluster::next\_\-serving, cluster::node\_\-count, cluster\_\-node::prev, cluster::rwlock, cluster::tail e cluster\_\-node::vlan\_\-ip.

Referenciado por cmd\_\-add\_\-node().\hypertarget{cluster_8h_4e116ec9395a6720c5f84de3e28b25a9}{
\index{cluster.h@{cluster.h}!get\_\-node\_\-by\_\-id@{get\_\-node\_\-by\_\-id}}
\index{get\_\-node\_\-by\_\-id@{get\_\-node\_\-by\_\-id}!cluster.h@{cluster.h}}
\subsubsection[get\_\-node\_\-by\_\-id]{\setlength{\rightskip}{0pt plus 5cm}struct {\bf cluster\_\-node}$\ast$ get\_\-node\_\-by\_\-id (int {\em id})\hspace{0.3cm}{\tt  \mbox{[}read\mbox{]}}}}
\label{cluster_8h_4e116ec9395a6720c5f84de3e28b25a9}


Busca um servidor do \hyperlink{structcluster}{cluster} pelo ID. 

\begin{Desc}
\item[Parâmetros:]
\begin{description}
\item[{\em id}]ID do \hyperlink{structcluster}{cluster} \end{description}
\end{Desc}


Definido na linha 180 do ficheiro cluster.h.

Referências cluster::head, cluster\_\-node::id, my\_\-cluster, cluster\_\-node::next e cluster::rwlock.

Referenciado por cmd\_\-my\_\-node() e nlb\_\-load\_\-heartbeat\_\-signal().\hypertarget{cluster_8h_28ab4480aefa945c08a4d1f5e16a8d5e}{
\index{cluster.h@{cluster.h}!hash\_\-remove\_\-node\_\-affinities@{hash\_\-remove\_\-node\_\-affinities}}
\index{hash\_\-remove\_\-node\_\-affinities@{hash\_\-remove\_\-node\_\-affinities}!cluster.h@{cluster.h}}
\subsubsection[hash\_\-remove\_\-node\_\-affinities]{\setlength{\rightskip}{0pt plus 5cm}void hash\_\-remove\_\-node\_\-affinities (struct {\bf cluster\_\-node} $\ast$ {\em node})}}
\label{cluster_8h_28ab4480aefa945c08a4d1f5e16a8d5e}


Remove todas as afinidades de um servidor Metodo usado na hora de remover um servidor do \hyperlink{structcluster}{cluster}. 

\begin{Desc}
\item[Parâmetros:]
\begin{description}
\item[{\em node}]Servidor do \hyperlink{structcluster}{cluster} \end{description}
\end{Desc}


Definido na linha 235 do ficheiro hash-afinidades.h.

Referências nlb\_\-affinity\_\-hash\_\-table::entries, nlb\_\-affinity\_\-hash\_\-table::hash\_\-mask, nlb\_\-affinity\_\-hash\_\-table::hash\_\-table, my\_\-nlb\_\-affinity\_\-hash\_\-table, nlb\_\-affinity::next e nlb\_\-affinity\_\-hash\_\-table::rwlock.

Referenciado por remove\_\-cluster\_\-node().\hypertarget{cluster_8h_25dbc05b5c8157863bcb1801c17f77c1}{
\index{cluster.h@{cluster.h}!hb\_\-broadcast\_\-msg@{hb\_\-broadcast\_\-msg}}
\index{hb\_\-broadcast\_\-msg@{hb\_\-broadcast\_\-msg}!cluster.h@{cluster.h}}
\subsubsection[hb\_\-broadcast\_\-msg]{\setlength{\rightskip}{0pt plus 5cm}int hb\_\-broadcast\_\-msg (char $\ast$ {\em buf}, \/  int {\em buf\_\-len})}}
\label{cluster_8h_25dbc05b5c8157863bcb1801c17f77c1}


Envia uma mensagem em Brodcast para todos os nós do \hyperlink{structcluster}{cluster}. 

\begin{Desc}
\item[Parâmetros:]
\begin{description}
\item[{\em buf}]Buffer da mensagem \item[{\em buf\_\-len}]Tamanho do buffer da mensagem \end{description}
\end{Desc}


Definido na linha 79 do ficheiro heartbeat.h.

Referências ksock\_\-thread\_\-t::addr\_\-send, ksocket\_\-send() e ksock\_\-thread\_\-t::sock.

Referenciado por hb\_\-udb\_\-client\_\-start() e remove\_\-cluster\_\-node().\hypertarget{cluster_8h_1cacc18d29de69dfe9b47ee4eb5e7600}{
\index{cluster.h@{cluster.h}!hb\_\-timer\_\-add@{hb\_\-timer\_\-add}}
\index{hb\_\-timer\_\-add@{hb\_\-timer\_\-add}!cluster.h@{cluster.h}}
\subsubsection[hb\_\-timer\_\-add]{\setlength{\rightskip}{0pt plus 5cm}void hb\_\-timer\_\-add (struct {\bf cluster\_\-node} $\ast$ {\em new\_\-node})}}
\label{cluster_8h_1cacc18d29de69dfe9b47ee4eb5e7600}


Prepara o servidor adicionado ao \hyperlink{structcluster}{cluster} para ser removido do \hyperlink{structcluster}{cluster} se nao receber o heartbeat. 

\begin{Desc}
\item[Parâmetros:]
\begin{description}
\item[{\em new\_\-node}]Servidor \end{description}
\end{Desc}


Definido na linha 38 do ficheiro heartbeat.h.

Referências cluster\_\-node::hb\_\-timer, HEARTBEAT\_\-TIMEOUT e remove\_\-cluster\_\-node().

Referenciado por add\_\-cluster\_\-node().\hypertarget{cluster_8h_33d0ab81e5ab7cf05146cead194236b7}{
\index{cluster.h@{cluster.h}!init\_\-cluster@{init\_\-cluster}}
\index{init\_\-cluster@{init\_\-cluster}!cluster.h@{cluster.h}}
\subsubsection[init\_\-cluster]{\setlength{\rightskip}{0pt plus 5cm}static int init\_\-cluster (char $\ast$ {\em dev}, \/  char $\ast$ {\em ip}, \/  int($\ast$)(struct sk\_\-buff $\ast$skb, struct net\_\-device $\ast${\bf dev}) {\em hard\_\-start\_\-xmit\_\-new})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{cluster_8h_33d0ab81e5ab7cf05146cead194236b7}


Inicializa a estrutura my\_\-cluster. 

\begin{Desc}
\item[Parâmetros:]
\begin{description}
\item[{\em dev}]Nome da interface de rede usada para o \hyperlink{structcluster}{cluster} \item[{\em ip}]IP virtual do \hyperlink{structcluster}{cluster} \item[{\em hard\_\-start\_\-xmit\_\-new}]Ponteiro para funcao que ira encapsular o metodo do driver de rede para modificar o cabecalho da camada de enlace \end{description}
\end{Desc}


Definido na linha 214 do ficheiro cluster.h.

Referências cluster::dev, cluster::hard\_\-start\_\-xmit\_\-old, cluster::mac\_\-response, my\_\-cluster, cluster::new\_\-ip\_\-addr, cluster::node\_\-count, parse\_\-ipv4\_\-addr() e cluster::rwlock.

Referenciado por nlb\_\-init\_\-module().\hypertarget{cluster_8h_aa5aa80302607600a63f6b78dc842b75}{
\index{cluster.h@{cluster.h}!nlb\_\-cluster\_\-exit@{nlb\_\-cluster\_\-exit}}
\index{nlb\_\-cluster\_\-exit@{nlb\_\-cluster\_\-exit}!cluster.h@{cluster.h}}
\subsubsection[nlb\_\-cluster\_\-exit]{\setlength{\rightskip}{0pt plus 5cm}static int nlb\_\-cluster\_\-exit (void)\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{cluster_8h_aa5aa80302607600a63f6b78dc842b75}


Finaliza o \hyperlink{structcluster}{cluster}. 



Definido na linha 265 do ficheiro cluster.h.

Referências cluster::dev, cluster::hard\_\-start\_\-xmit\_\-old, cluster\_\-node::hb\_\-timer, cluster::head, my\_\-cluster e cluster\_\-node::next.

Referenciado por nlb\_\-exit\_\-module().\hypertarget{cluster_8h_c55a15a79cadec11fb3d6df11ac5f4e7}{
\index{cluster.h@{cluster.h}!remove\_\-cluster\_\-node@{remove\_\-cluster\_\-node}}
\index{remove\_\-cluster\_\-node@{remove\_\-cluster\_\-node}!cluster.h@{cluster.h}}
\subsubsection[remove\_\-cluster\_\-node]{\setlength{\rightskip}{0pt plus 5cm}void remove\_\-cluster\_\-node (unsigned long {\em node\_\-ptr})}}
\label{cluster_8h_c55a15a79cadec11fb3d6df11ac5f4e7}


Remove um servidor do \hyperlink{structcluster}{cluster}\begin{itemize}
\item Remove o servidor da lista de servidores,\item Notifica os demais servidores da exclusao deste servidor. \end{itemize}


\begin{Desc}
\item[Parâmetros:]
\begin{description}
\item[{\em node\_\-ptr}]Ponteiro para o servidor do \hyperlink{structcluster}{cluster} \end{description}
\end{Desc}


Definido na linha 125 do ficheiro cluster.h.

Referências hash\_\-remove\_\-node\_\-affinities(), hb\_\-broadcast\_\-msg(), cluster::head, cluster\_\-node::id, my\_\-cluster, cluster\_\-node::next, cluster::next\_\-serving, cluster::node\_\-count, cluster\_\-node::prev, cluster::rwlock e cluster::tail.

Referenciado por hb\_\-timer\_\-add() e nlb\_\-load\_\-heartbeat\_\-signal().

\subsection{Documentação das variáveis}
\hypertarget{cluster_8h_1917b2709741dea7ce5cf6ea441686ed}{
\index{cluster.h@{cluster.h}!my\_\-cluster@{my\_\-cluster}}
\index{my\_\-cluster@{my\_\-cluster}!cluster.h@{cluster.h}}
\subsubsection[my\_\-cluster]{\setlength{\rightskip}{0pt plus 5cm}struct {\bf cluster}  {\bf my\_\-cluster}}}
\label{cluster_8h_1917b2709741dea7ce5cf6ea441686ed}


Cluster. 



Referenciado por add\_\-cluster\_\-node(), cmd\_\-my\_\-node(), dev\_\-cluster\_\-hard\_\-start\_\-xmit\_\-new(), get\_\-node\_\-by\_\-id(), hb\_\-rebuild\_\-msg(), init\_\-cluster(), nlb\_\-cluster\_\-exit(), nlb\_\-hook\_\-in(), nlb\_\-init\_\-module(), procfile\_\-read() e remove\_\-cluster\_\-node().\hypertarget{cluster_8h_39e3ce09327c335c6a58f152f9d8fbbf}{
\index{cluster.h@{cluster.h}!my\_\-node@{my\_\-node}}
\index{my\_\-node@{my\_\-node}!cluster.h@{cluster.h}}
\subsubsection[my\_\-node]{\setlength{\rightskip}{0pt plus 5cm}struct {\bf cluster\_\-node}  {\bf my\_\-node}}}
\label{cluster_8h_39e3ce09327c335c6a58f152f9d8fbbf}


Nó do \hyperlink{structcluster}{cluster}. 



Referenciado por cmd\_\-my\_\-node().